package es

import (
	"fmt"
	"github.com/elastic/go-elasticsearch/v8"
)

// 创建es连接，并进行初始化

var EsClient *elasticsearch.TypedClient

func InitEsConn() {
	// ES配置
	cfg := elasticsearch.Config{
		Addresses: []string{
			"http://localhost:9200",
		},
	}
	// 创建客户端连接
	client, err := elasticsearch.NewTypedClient(cfg)
	if err != nil {
		fmt.Println("elasticsearch.NewTypedClient failed, err:%v\n")
		panic(err)
	}
	EsClient = client
}
